﻿@model IQueryable<SusuCMS.Page>
@using System.Web.Helpers;
@{
    ViewBag.Title = "Page List".Localize();
}
<h2>
    @("Page List".Localize())</h2>
<div class="toolbar">
    @Html.ActionLink("Create", "Create", "Page", null, new { @class = "button" })
    @using (Html.BeginForm("Search", "Page", FormMethod.Get))
    {
        @Html.TextBox("Keywords")
        <button type="submit">@("Search".Localize())</button>
    }
</div>
@{
    var grid = new WebGrid(Model);
}
@using (Html.BeginForm("Delete", "Page"))
{
    @grid.GetHtml(
        tableStyle: "data-table",
        columns: grid.Columns(
            grid.Column("Id", "Id".Localize()),
            grid.Column("Title", "Title".Localize()),
            grid.Column("Url", "Url".Localize()),
            grid.Column("CreateTime", "CreateTime".Localize()),
            grid.Column("IsPublished", "IsPublished".Localize(), format: (item) => Html.ActionLink("IsPublished", "ToggleOnline", "Page", new { id = item.Id, returnUrl = Request.RawUrl }, new { @class = item.IsPublished.ToString().ToLower() })),
            grid.Column(header: "Edit".Localize(), format: (item) => Html.ActionLink("Edit".Localize(), "Edit", "Page", new { id = item.Id, returnUrl = Request.RawUrl }, new { @class = "edit" })),
            grid.Column(header: "Delete".Localize(), format: (item) => Html.Raw(string.Format("<button type=\"submit\" name=\"id\" value=\"{0}\" class=\"delete\">{1}</button>", item.Id, "Delete".Localize())))
            )
       )
}